package com.bfs.anasit.service;

import com.bfs.anasit.model.AnasitUser;
import com.bfs.anasit.repository.AnasitUserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: lukman
 * Date: 6/12/11
 * Time: 10:08 PM
 * To change this template use File | Settings | File Templates.
 */
@Service("anasitUserService")
@Named("anasitUserService")
@SessionScoped
public class AnasitUserServiceImpl implements AnasitUserService {

    @SuppressWarnings("unused")
    @PersistenceContext
    private EntityManager em;

    @Autowired
    private AnasitUserRepository anasitUserRepository;


    @Override
    public AnasitUser findById(Long Id) {
        return anasitUserRepository.findOne(Id);
    }

    @Override
    public List<AnasitUser> findAllAnasitUsers() {
        return anasitUserRepository.findAll();
    }

    @Override
    public AnasitUser update(AnasitUser anasitUser) {
        return anasitUserRepository.save(anasitUser);
    }

    @Override
    public void delete(AnasitUser anasitUser) {
        anasitUserRepository.delete(anasitUser);
    }

    @Override
    public AnasitUser save(AnasitUser anasitUser) {
        return anasitUserRepository.save(anasitUser);
    }

    @Override
    public List<AnasitUser> findAllAnasitUsers(Sort sort) {
        return anasitUserRepository.findAll(sort);
    }
}
